<template>
	<view class="page" :style="'height:' + height + 'rpx'">
<!-- 		<view class="top">
			<button class="sure" @click="sure()">确定</button>
		</view> -->
		<view class="content">
			<view class="item" v-for="(item,index) in currentChoose" :key="index" :id="'id-' + index">
				<view class="person_sex iconfont icon-fl-renyuan"
					:style="{'color': (item.source.sex == '男' ? '#3d8cff':'#EE82EE')}"></view>
				<view class="person_name">{{item.source.name}}</view>
				<view class="close iconfont icon-guanbi" @click="close(index)">
					<!-- <text class="iconfont icon-guanbi"></text> -->
				</view>
			</view>
		</view>
		<view class="noDataTip" v-if="currentChoose.length == 0">
			<view class="iconfont icon-wuanpai" style="color:#6B6B6B;margin-right: 25rpx;font-size: 45rpx;"></view>
			<view style="font-size: 45rpx;">已无人员数据!</view>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad(options) {
			this.header = getApp().globalData.header;
			this.situation = options.situation;
			if (this.situation == "'addSomeOneCan'") {
				this.detailPrivacygetting(3)
			} else if (this.situation == "'addSomeOneCanNot'") {
				this.detailPrivacygetting(4)
			}
			let that = this;
			uni.getSystemInfo({
				success: function(res) {
					let pxToRpxScale = 750 / res.windowWidth;
					// console.log(res.windowHeight);

					that.height = res.windowHeight * pxToRpxScale;
					// console.log(that.height)
				}
			});
			
			// this.currentChoose = JSON.parse(options.currentChoose)

		},
		data() {
			return {
				height: 0,
				situation: '',
				currentChoose: [],
				privacySettingParams: {  //权限设置参数
					list: [],
					setting: ""
				},
				deleteParams : {
					targetNo: "",
					setting: ""
				},
				header: null
			}
		},
		methods: {
			
			//删除某一成员
			close(index) {
				let that = this;
				// console.log('删除');
				uni.showModal({
				    title: '提示',
				    content: '确定删除此成员？',
				    success: function (res) {
				        if (res.confirm) {
				           that.deleteMember(that.currentChoose[index].source.no)
				           that.currentChoose.splice(index,1)
				        } else if (res.cancel) {
				        }
				    }
				});
			},
			
		
			//查看只给谁看或不给谁看具体的人
			async detailPrivacygetting(index) {
				let params = {
					setting: ''
				}
				params.setting = index
				let res = await getApp().UniRequest("/mita/authority/detailPrivacySetting", "Get", params,
					this.header);
				if (res.code === 20000) {
					this.currentChoose = res.data.list;
					uni.showToast({
						title: '删除成功',
						icon: 'success',
						duration: 2000
					});
				} else {
					uni.showToast({
						title: '请稍后重试',
						icon: 'error',
						duration: 2000
					});
				}

			},
			// 	//提交数据
			// sure() {
			// 	let that = this;
			// 	let header = new Object()
			// 	header.Authority = uni.getStorageSync("Authority");
			// 	let temp = (this.situation == "'addSomeOneCan'");
			// 	console.log('当前选中',this.currentChoose)
			// 	this.currentChoose.forEach((item,index) => {
			// 		this.privacySettingParams.list.push(item.source.no)
			// 	})
				
			// 	if (this.situation == "'addSomeOneCan'") {
			// 		this.privacySettingParams.setting = 3;
			// 	} else if (this.situation == "'addSomeOneCanNot'") {
			// 		this.privacySettingParams.setting = 4;
			// 	}
			// 	console.log(this.privacySettingParams)
			//     uni.request({
			// 		url: 'http://159.75.241.252:9001/zkCourse/mita/authority/detailPrivacySetting',
			// 		header: header,
			// 		method: 'POST',
			// 		data: this.privacySettingParams,
			// 		success: (res) => {
			// 			console.log('设置结果',res);
			// 			if (res.data.code === 20000) {
			// 				console.log('删除');
			// 					uni.redirectTo({
			// 						url: '../miTaRight/miTaRight?' + '&addSomeOneCan=' +  temp
			// 					});
			// 			}
			// 		},
			// 		fail(error) {
			// 			console.log(error)
			// 		}
			// 	});
			// },
			async deleteMember(no) {
				// console.log('要删除',no);
				if (this.situation == "'addSomeOneCan'") {
					this.deleteParams.setting = 3;
				} else if (this.situation == "'addSomeOneCanNot'") {
					this.deleteParams.setting = 4;
				}
				this.deleteParams.targetNo = no;
				// console.log(this.deleteParams)
				let res = await getApp().UniRequest("/mita/authority/detailPrivacySetting?targetNo=" + this.deleteParams.targetNo + '&setting=' + this.deleteParams.setting, "DELETE", "",
					this.header);
				// console.log('删除结果',res);
				if (res.code === 20000) {
					// console.log('删除成功');
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.page {
		padding: 20rpx;
		background-color: #f8f8f8;
		position: relative;
		button {
			background-color: #fff;
			border: 0rpx;
			padding-right: 10rpx;
			padding-left: 10rpx;
		}
		.noDataTip {
			height: 150rpx;
			width: 650rpx;
			line-height: 50rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			position: absolute;
			top: 50%;
			margin-top: -150rpx;
			left: 50%;
			margin-left: -325rpx;
			font-size: 50rpx;
			color: #6B6B6B;
			// background-color: #fff;
			// box-shadow: 0.5rpx 0.5rpx 40rpx #DBDBDB;
			border-radius: 20rpx;
		}

		.top {
			width: 100%;
			height: 80rpx;
			position: relative;

			.sure {
				width: 120rpx;
				height: 60rpx;
				position: absolute;
				top: 10rpx;
				right: 0rpx;
				font-size: 26rpx;
				background-color: #23b8ff;
				color: #FFFFFF;
			}
		}

		.content {
			display: flex;
			flex-wrap: wrap;

			.item {
				position: relative;
				width: 120rpx;
				height: 120rpx;
				padding-left: 10rpx;
				padding-right: 10rpx;
				margin-left: 20rpx;
				margin-top: 20rpx;
				background-color: #F0F0F0;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				// border: 1rpx solid #8A8A8A;
				box-shadow: 0.5rpx 0.5rpx 10rpx #D9D9D9;
				border-radius: 10rpx;
				letter-spacing: 2rpx;
				color: #737373;


				.person_sex {
					font-size: 50rpx;
				}

				.person_name {
					width: 100%;
					font-size: 24rpx;
					text-align: center;
					white-space: nowrap; //超出隐藏
					overflow: hidden;
					text-overflow: ellipsis;

				}

				.close {
					width: 30rpx;
					height: 30rpx;
					border-radius: 50%;
					// background-color: pink;
					position: absolute;
					top: 2%;
					right: 5%;
					background: rgba(0, 0, 0, 0.3);
					line-height: 30rpx;
					text-align: center;
					font-size: 20rpx;
					font-weight: 700;
					color: #E5E5E5;
				}
			}
		}
	}
</style>
